package com.study.example.gameserver.module.ranklist.handler.data;

import org.jetbrains.annotations.NotNull;

public class LevelRankData implements Comparable<LevelRankData> {
    private int level;
    private int exp;
    private long time;

    public LevelRankData() {

    }

    public LevelRankData(int value, long time) {
        this.level = value;
        this.time = time;
    }

    public int getLevel() {
        return level;
    }

    public long getTime() {
        return time;
    }

    public void setLevel(int level) {
        this.level = level;
    }

    public int getExp() {
        return exp;
    }

    public void setExp(int exp) {
        this.exp = exp;
    }

    public void setTime(long time) {
        this.time = time;
    }

    @Override
    public int compareTo(@NotNull LevelRankData o) {
        // 先比较 value
        int c1 = Integer.compare(this.level, o.level);
        if (c1 != 0) {
            return c1;
        }
        int c2 = Integer.compare(o.exp, this.exp);
        if (c2 != 0) {
            return c2;
        }
        // value 相等再比较 time
        return Long.compare(this.time, o.time);
    }

    @Override
    public String toString() {
        return "SimpleRankData{" +
                "value=" + level +
                ", time=" + time +
                '}';
    }
}
